1. Field of the Invention
The present invention concerns a method for storing data associated with an object (in the sense of object-oriented programming) in another data structure called a packet.
It also concerns a method of depackaging this other data structure to reconstruct an object similar to the original object.
The invention has one application in transmitting an object via a data processing network or for storing it on a data storage medium.
2. Description of the Prior Art
Object-oriented programming is based on the concepts of class, objects and inheritance.
From a very general point of view an object can be seen as a structure comprising a set of data (known as attributes) and a set of processes for manipulating the data (known as methods). Each object is an instance of a class.
Inheritance is a relation between two classes in which one is deemed to be the ancestor of the other. A class A inheriting from a class B inherits all its attributes and methods.
More comprehensive definitions of the above concepts can be found in various works covering object-oriented programming. Examples include Object-Oriented Design With Applications by Booch and Grady, 1991, or the C++ Programming Language (2nd edition) by Bjarne Stroupstrup, 1991, or Dictionary of Computing, Oxford University Press, 1990.
The concept of inheritance implies that an attribute (or a method) associated with a particular object can be either local to the class corresponding to that object or inherited from a parent class of that class.
To clarify this concept refer to the accompanying FIG. 1 which shows one example of an inheritance tree. Class C5 inherits from classes C3 and C4. Class C4 inherits from classes C1 and C2. The attributes associated with class C5 are e and f, which are local attributes, and a, b, c and d, which are inherited from classes C1, C3 and C4.
Consequently, storing the values of attributes associated with an object cannot be effected with reference only to that object. To the contrary, it is necessary to consider all of the inheritance tree of which its class is part.
A first aim of the present invention is to propose a method of storing the values of attributes associated with an object in another data structure (known as a packet) to facilitate transferring those values via a network or their storage on a data storage medium.
To this end, the invention consists in a method of storing in a packet attributes associated with an object corresponding to a class that is part of an inheritance tree, each class in the inheritance tree including a storage method including an index parameter, the method comprising the following steps:
calling storage methods of parent classes, if any, incrementing the index parameter,
placing a first free address in the packet into the packet at an address determined by the index parameter, and
copying attributes of a current class into the packet from the first free address with an identifier of the current class,
and the method calling the storage method of the corresponding class with a null value of the index parameter.
A second object of the present invention is to propose a method of depackaging the attributes stored in the above manner in order to reconstruct the original object. To this end the method of the invention includes the following steps:
calling the builders of parent classes, if any, fixing the value of the index parameter,
recovering a data address in the packet at an address determined by the index parameter,
recovering values of attributes in the packet at the data address.
The various advantages and features of the invention will become more apparent in the following description with reference to the accompanying drawings.